package com.cos.lession77.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Date;

/**
 * @author: COS
 * @time: 2022/10/10 15:18
 * @description:
 */
@Configuration
@EnableSwagger2 //启动api说明文档的生成
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig {

    @Bean
    public Docket getDocket(){
        ApiInfo a  = new ApiInfoBuilder()
                .title("qf2204 emp api 文档")
                .description("qf2204 写的挫挫的玩意")
                .contact(new Contact("2204", "https://www.baidu.com","3258536913@qq.com"))
                .version("v1.0")
                .build();
        Docket d  = new Docket(DocumentationType.SWAGGER_2)//设置说明风格配置
                    .apiInfo(a) //设置api 文档信息
                    .select() // 获取选择器
                    .apis(RequestHandlerSelectors.basePackage("com.cos.lession77.web.controller"))// 选择controller下的类需要进行说明文档生成
//                    .paths(PathSelectors.regex("/emp/**"))
                    .paths(PathSelectors.any()) //设置controller里面所有的请求都需要设置 说明文档生成
                    .build();
        return d;
    }


}
